<script src="{:cdn('PUBLIC')}/app/datatable/js/jquery.dataTables.min.js" type="text/javascript"></script>
<style>
	.searchBar{height:auto;}
	.searchContent {width:auto; display:inline; float:auto; height:200px;}
	.searchBar ul.searchContent {height:auto;}
	.searchContent input {width:150px;display:inline;}
	#suggest ul{width:250px;}
</style>
<script>
	function exports(obj)
	{
		//查找table的节点，提交给后台
        var data = $(obj).parent().parent().parent().parent().find("table");
        var dt = new Date();
        var day = dt.getDate();
        var month = dt.getMonth() + 1;
        var year = dt.getFullYear();
        var hour = dt.getHours();
        var mins = dt.getMinutes();
        var postfix = day + "." + month + "." + year + "_" + hour + "." + mins;
        var a = document.createElement('a');
        var data_type = 'data:application/vnd.ms-excel';
        var head = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>";
        var table_html = head + data.html().replace(/ /g, '%20') + "</table></body></html>";
        a.href = data_type + ', ' + table_html;
        a.download = 'exported_table_' + postfix + '.xls';
        a.click();
        obj.preventDefault();
	}
</script>
<div class="pageContent">
	<div class="panel collapse" >
		<h1>{:D("SysConfig")->getValue('ANALYSIS_NOTE');}</h1>
		<div class="searchBar">
			<form id="pagerForm" onsubmit="return divSearch(this, '<?php echo $page_id=rand();?>');"
			action="{:U("search")}" method="post">
			<ul class="searchContent">
				<li>
					<label>开始时间：</label>
					<input name="start_day" value="{:date('Y-m-d', strtotime('-7 day'))}" class="date" readonly="true" />
				</li>
				
				<li>
					<label>截止时间：</label>
					<input name="end_day" value="{:date('Y-m-d', strtotime('-1 day'))}" class="date" readonly="true" />
					<select id="lastdate">
						<option value="d7">最近一周</option>
						<option value="d14">最近两周</option>
						<option value="d31">最近一月</option>
						<option value="w1">本周</option>
						<option value="m1">本月</option>
					</select>
				</li>
				
				<script>
					$("#lastdate").change(function(){
						var s = {
								"d7":["<?php echo date('Y-m-d', strtotime('-7 day'));?>", "<?php echo date('Y-m-d', strtotime('-1 day'));?>"],
								"d14":["<?php echo date('Y-m-d', strtotime('-14 day'));?>", "<?php echo date('Y-m-d', strtotime('-1 day'));?>"],
								"d31":["<?php echo date('Y-m-d', strtotime('-31 day'));?>", "<?php echo date('Y-m-d', strtotime('-1 day'));?>"],
								"w1":["<?php echo date('Y-m-d', strtotime('this week'));?>", "<?php echo date('Y-m-d', strtotime('-1 day'));?>"],
								"m1":["<?php echo date('Y-m-01', strtotime('-1 day'));?>", "<?php echo date('Y-m-d', strtotime('-1 day'));?>"],
						};
						var d = $(this).val();
						
						for (var k in s) {
							if (k == d) {
								$("input[name=start_day]").val(s[k][0]);
								$("input[name=end_day]").val(s[k][1]);
							}
						}
					});
				</script>

				<li>
					<label>渠道名称：</label>
					<input id="inputChannel" name="channel.name" value="" placeholder="{$channel}" type="text" postField="keyword" suggestFields="name" 
					suggestUrl="{:U("versionList", ["get"=>"channel"])}" lookupGroup="channel"
					ondblclick="this.value='';this.blur();this.focus();"
					/>
				</li>
				<li>
					<label>版本号：</label>
					<!--<input name="vcode.id" value="" placeholder="*" type="text" postField="keyword" suggestFields="name"-->
						   <!--suggestUrl="{:U("versionList", ["get"=>"vcode"])}" lookupGroup="vcode"-->
					<!--ondblclick="this.value='';this.blur();this.focus();"-->
					<input name="vcode" value="" placeholder="*" type="text">
				</li>
				<li>
					<label>国家：</label>
					<input name="country.id" value="" placeholder="*" type="text" postField="keyword" suggestFields="name" 
					suggestUrl="{:U("geo")}" lookupGroup="country"
					ondblclick="this.value='';this.blur();this.focus();"

				</li>
				<li>
					<label>版本：</label>
					<select class="combox" name="sdk">
						<option value="">请选择</option>
						<option value="14">Android 4.0–4.0.2</option>
						<option value="15">Android 4.0.3–4.0.4</option>
						<option value="16">Android 4.1–4.1.2</option>
						<option value="17">Android 4.2–4.2.2</option>
						<option value="18">Android 4.3–4.3.1</option>
						<option value="19">Android 4.4–4.4.4</option>
						<option value="20">Android 4.4W–4.4W.2</option>
						<option value="21">Android 5.0–5.0.2</option>
						<option value="22">Android 5.1–5.1.1</option>
						<option value="23">Android 6.0–6.0.1</option>
						<option value="5">Android 2.0</option>
						<option value="6">Android 2.0.1</option>
						<option value="7">Android 2.1</option>
						<option value="8">Android 2.2–2.2.3</option>
						<option value="9">Android 2.3–2.3.2</option>
						<option value="10">Android 2.3.3–2.3.7</option>
						<option value="11">Android 3.0</option>
						<option value="12">Android 3.1</option>
						<option value="13">Android 3.2–3.2.6</option>
					</select>
				</li>

				<php>if(admin_id() == 1 && 'AnalysisOffer' == CONTROLLER_NAME) :</php>
					<li>
                            <label>From：</label>
                            {:Helper("Form")->name('from')->class("combox")->option($froms)->select()}
                    </li>
					<li>
						<label>OfferId：</label>
						<input name="offer.id" value="0" type="hidden">
						<input name="offer.name" value="" placeholder="*" type="text" postField="keyword" suggestFields="name" 
						suggestUrl="{:U("offer_id")}" lookupGroup="offer"
						ondblclick="this.value='';this.blur();this.focus();"
						/>
					</li>
				<php>endif</php>

				<input type="hidden" name="group" value="{$group}">

				<php>if('AnalysisOffer' == CONTROLLER_NAME || 'Analysis' == CONTROLLER_NAME) :</php>
				<li>
					<label>无感知插件类型：</label>
					{:Helper("Form")->name('plugin')->class("combox")->option($plugins)->select()}
				</li>
				<php>endif</php>

				<php>if('AnalysisOffer' == CONTROLLER_NAME) :</php>
				<li>
					<label>是否拦截：</label>
					<select class="combox" name="rob" id="rob">
						<option value="0">否</option>
						<option value="1">是</option>
					</select>
				</li>
				<php>endif</php>

				
				<li>
					<label>时区：</label>
					<input name="timezone.id" id="timezone" value="+08:00" type="hidden">
					<input name="timezone.name" value="" placeholder="+08:00 北京时间" type="text" postField="keyword" suggestFields="name"
					suggestUrl="{:U("timezoneList")}" lookupGroup="timezone" 
					ondblclick="this.value='';this.blur();this.focus();document.getElementById('timezone').value='+08:00';" 
					title="双击清空" 
					/>
				</li>
				<li>
					<label>除重条件：</label>
					<select class="combox" name="uniq">
						<option value="uuid">UUID</option>
						<option value="imei">IMEI</option>
						<option value="device_md5">DEVICE_MD5</option>
					</select>
				</li>
                <div class="buttonActive"><div class="buttonContent"><button type="submit">查询</button></div></div>
			</ul>
			</form>
		</div>
	</div>
	
	<div id="{$page_id}" class="unitBox" style="padding:0 5px 0 5px;">
	</div>
</div>
